Optimal. Leaf size=107 \[ \frac {6 a^2 b \tanh ^{-1}\left (\frac {-b+a \tan \left (\frac {x}{2}\right )}{\sqrt {a^2+b^2}}\right )}{\left (a^2+b^2\right )^{5/2}}+\frac {3 a \left (a^2-b^2\right )+a \left (a^2+b^2\right ) \cos (2 x)-b \left (a^2+b^2\right ) \sin (2 x)}{2 \left (a^2+b^2\right )^2 (a \cos (x)+b \sin (x))} \]
[Out]
________________________________________________________________________________________
Rubi [B] Leaf count is larger than twice the leaf count of optimal. \(283\) vs. \(2(107)=214\).
time = 0.87, antiderivative size = 283, normalized size of antiderivative = 2.64, number of steps
used = 19, number of rules used = 11, integrand size = 16, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.688, Rules used = {4486, 2717,
2718, 6874, 653, 209, 652, 632, 212, 3179, 3153} \begin {gather*} \frac {3 a^2 \cos (x)}{b^2 \left (a^2+b^2\right )}+\frac {2 a^2 \left (a+b \tan \left (\frac {x}{2}\right )\right )}{\left (a^2+b^2\right )^2 \left (-a \tan ^2\left (\frac {x}{2}\right )+a+2 b \tan \left (\frac {x}{2}\right )\right )}+\frac {2 a^2 \left (3 a^2+b^2\right ) \tanh ^{-1}\left (\frac {b-a \tan \left (\frac {x}{2}\right )}{\sqrt {a^2+b^2}}\right )}{b \left (a^2+b^2\right )^{5/2}}-\frac {2 a^2 b \tanh ^{-1}\left (\frac {b-a \tan \left (\frac {x}{2}\right )}{\sqrt {a^2+b^2}}\right )}{\left (a^2+b^2\right )^{5/2}}-\frac {3 a^2 \tanh ^{-1}\left (\frac {b \cos (x)-a \sin (x)}{\sqrt {a^2+b^2}}\right )}{b \left (a^2+b^2\right )^{3/2}}+\frac {3 a^3 \sin (x)}{b^3 \left (a^2+b^2\right )}-\frac {2 a^3 \cos ^2\left (\frac {x}{2}\right ) \left (\left (a^2-b^2\right ) \tan \left (\frac {x}{2}\right )+2 a b\right )}{b^3 \left (a^2+b^2\right )^2}-\frac {2 a \sin (x)}{b^3}-\frac {\cos (x)}{b^2} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
Rule 209
Rule 212
Rule 632
Rule 652
Rule 653
Rule 2717
Rule 2718
Rule 3153
Rule 3179
Rule 4486
Rule 6874
Rubi steps
\begin {align*} \int \frac {\sin ^3(x)}{(a \cos (x)+b \sin (x))^2} \, dx &=\int \left (-\frac {2 a \cos (x)}{b^3}+\frac {\sin (x)}{b^2}-\frac {a^3 \cos ^3(x)}{b^3 (a \cos (x)+b \sin (x))^2}+\frac {3 a^2 \cos ^2(x)}{b^3 (a \cos (x)+b \sin (x))}\right ) \, dx\\ &=-\frac {(2 a) \int \cos (x) \, dx}{b^3}+\frac {\left (3 a^2\right ) \int \frac {\cos ^2(x)}{a \cos (x)+b \sin (x)} \, dx}{b^3}-\frac {a^3 \int \frac {\cos ^3(x)}{(a \cos (x)+b \sin (x))^2} \, dx}{b^3}+\frac {\int \sin (x) \, dx}{b^2}\\ &=-\frac {\cos (x)}{b^2}+\frac {3 a^2 \cos (x)}{b^2 \left (a^2+b^2\right )}-\frac {2 a \sin (x)}{b^3}-\frac {\left (2 a^3\right ) \text {Subst}\left (\int \frac {\left (1-x^2\right )^3}{\left (1+x^2\right )^2 \left (a+2 b x-a x^2\right )^2} \, dx,x,\tan \left (\frac {x}{2}\right )\right )}{b^3}+\frac {\left (3 a^3\right ) \int \cos (x) \, dx}{b^3 \left (a^2+b^2\right )}+\frac {\left (3 a^2\right ) \int \frac {1}{a \cos (x)+b \sin (x)} \, dx}{b \left (a^2+b^2\right )}\\ &=-\frac {\cos (x)}{b^2}+\frac {3 a^2 \cos (x)}{b^2 \left (a^2+b^2\right )}-\frac {2 a \sin (x)}{b^3}+\frac {3 a^3 \sin (x)}{b^3 \left (a^2+b^2\right )}-\frac {\left (2 a^3\right ) \text {Subst}\left (\int \left (\frac {2 \left (a^2-b^2-2 a b x\right )}{\left (a^2+b^2\right )^2 \left (1+x^2\right )^2}+\frac {-a^2+b^2}{\left (a^2+b^2\right )^2 \left (1+x^2\right )}-\frac {2 b^3 x}{a \left (a^2+b^2\right ) \left (-a-2 b x+a x^2\right )^2}-\frac {b^2 \left (3 a^2+b^2\right )}{a \left (a^2+b^2\right )^2 \left (-a-2 b x+a x^2\right )}\right ) \, dx,x,\tan \left (\frac {x}{2}\right )\right )}{b^3}-\frac {\left (3 a^2\right ) \text {Subst}\left (\int \frac {1}{a^2+b^2-x^2} \, dx,x,b \cos (x)-a \sin (x)\right )}{b \left (a^2+b^2\right )}\\ &=-\frac {3 a^2 \tanh ^{-1}\left (\frac {b \cos (x)-a \sin (x)}{\sqrt {a^2+b^2}}\right )}{b \left (a^2+b^2\right )^{3/2}}-\frac {\cos (x)}{b^2}+\frac {3 a^2 \cos (x)}{b^2 \left (a^2+b^2\right )}-\frac {2 a \sin (x)}{b^3}+\frac {3 a^3 \sin (x)}{b^3 \left (a^2+b^2\right )}-\frac {\left (4 a^3\right ) \text {Subst}\left (\int \frac {a^2-b^2-2 a b x}{\left (1+x^2\right )^2} \, dx,x,\tan \left (\frac {x}{2}\right )\right )}{b^3 \left (a^2+b^2\right )^2}+\frac {\left (2 a^3 \left (a^2-b^2\right )\right ) \text {Subst}\left (\int \frac {1}{1+x^2} \, dx,x,\tan \left (\frac {x}{2}\right )\right )}{b^3 \left (a^2+b^2\right )^2}+\frac {\left (4 a^2\right ) \text {Subst}\left (\int \frac {x}{\left (-a-2 b x+a x^2\right )^2} \, dx,x,\tan \left (\frac {x}{2}\right )\right )}{a^2+b^2}+\frac {\left (2 a^2 \left (3 a^2+b^2\right )\right ) \text {Subst}\left (\int \frac {1}{-a-2 b x+a x^2} \, dx,x,\tan \left (\frac {x}{2}\right )\right )}{b \left (a^2+b^2\right )^2}\\ &=\frac {a^3 \left (a^2-b^2\right ) x}{b^3 \left (a^2+b^2\right )^2}-\frac {3 a^2 \tanh ^{-1}\left (\frac {b \cos (x)-a \sin (x)}{\sqrt {a^2+b^2}}\right )}{b \left (a^2+b^2\right )^{3/2}}-\frac {\cos (x)}{b^2}+\frac {3 a^2 \cos (x)}{b^2 \left (a^2+b^2\right )}-\frac {2 a \sin (x)}{b^3}+\frac {3 a^3 \sin (x)}{b^3 \left (a^2+b^2\right )}-\frac {2 a^3 \cos ^2\left (\frac {x}{2}\right ) \left (2 a b+\left (a^2-b^2\right ) \tan \left (\frac {x}{2}\right )\right )}{b^3 \left (a^2+b^2\right )^2}+\frac {2 a^2 \left (a+b \tan \left (\frac {x}{2}\right )\right )}{\left (a^2+b^2\right )^2 \left (a+2 b \tan \left (\frac {x}{2}\right )-a \tan ^2\left (\frac {x}{2}\right )\right )}-\frac {\left (2 a^2 b\right ) \text {Subst}\left (\int \frac {1}{-a-2 b x+a x^2} \, dx,x,\tan \left (\frac {x}{2}\right )\right )}{\left (a^2+b^2\right )^2}-\frac {\left (2 a^3 \left (a^2-b^2\right )\right ) \text {Subst}\left (\int \frac {1}{1+x^2} \, dx,x,\tan \left (\frac {x}{2}\right )\right )}{b^3 \left (a^2+b^2\right )^2}-\frac {\left (4 a^2 \left (3 a^2+b^2\right )\right ) \text {Subst}\left (\int \frac {1}{4 \left (a^2+b^2\right )-x^2} \, dx,x,-2 b+2 a \tan \left (\frac {x}{2}\right )\right )}{b \left (a^2+b^2\right )^2}\\ &=-\frac {3 a^2 \tanh ^{-1}\left (\frac {b \cos (x)-a \sin (x)}{\sqrt {a^2+b^2}}\right )}{b \left (a^2+b^2\right )^{3/2}}+\frac {2 a^2 \left (3 a^2+b^2\right ) \tanh ^{-1}\left (\frac {b-a \tan \left (\frac {x}{2}\right )}{\sqrt {a^2+b^2}}\right )}{b \left (a^2+b^2\right )^{5/2}}-\frac {\cos (x)}{b^2}+\frac {3 a^2 \cos (x)}{b^2 \left (a^2+b^2\right )}-\frac {2 a \sin (x)}{b^3}+\frac {3 a^3 \sin (x)}{b^3 \left (a^2+b^2\right )}-\frac {2 a^3 \cos ^2\left (\frac {x}{2}\right ) \left (2 a b+\left (a^2-b^2\right ) \tan \left (\frac {x}{2}\right )\right )}{b^3 \left (a^2+b^2\right )^2}+\frac {2 a^2 \left (a+b \tan \left (\frac {x}{2}\right )\right )}{\left (a^2+b^2\right )^2 \left (a+2 b \tan \left (\frac {x}{2}\right )-a \tan ^2\left (\frac {x}{2}\right )\right )}+\frac {\left (4 a^2 b\right ) \text {Subst}\left (\int \frac {1}{4 \left (a^2+b^2\right )-x^2} \, dx,x,-2 b+2 a \tan \left (\frac {x}{2}\right )\right )}{\left (a^2+b^2\right )^2}\\ &=-\frac {3 a^2 \tanh ^{-1}\left (\frac {b \cos (x)-a \sin (x)}{\sqrt {a^2+b^2}}\right )}{b \left (a^2+b^2\right )^{3/2}}-\frac {2 a^2 b \tanh ^{-1}\left (\frac {b-a \tan \left (\frac {x}{2}\right )}{\sqrt {a^2+b^2}}\right )}{\left (a^2+b^2\right )^{5/2}}+\frac {2 a^2 \left (3 a^2+b^2\right ) \tanh ^{-1}\left (\frac {b-a \tan \left (\frac {x}{2}\right )}{\sqrt {a^2+b^2}}\right )}{b \left (a^2+b^2\right )^{5/2}}-\frac {\cos (x)}{b^2}+\frac {3 a^2 \cos (x)}{b^2 \left (a^2+b^2\right )}-\frac {2 a \sin (x)}{b^3}+\frac {3 a^3 \sin (x)}{b^3 \left (a^2+b^2\right )}-\frac {2 a^3 \cos ^2\left (\frac {x}{2}\right ) \left (2 a b+\left (a^2-b^2\right ) \tan \left (\frac {x}{2}\right )\right )}{b^3 \left (a^2+b^2\right )^2}+\frac {2 a^2 \left (a+b \tan \left (\frac {x}{2}\right )\right )}{\left (a^2+b^2\right )^2 \left (a+2 b \tan \left (\frac {x}{2}\right )-a \tan ^2\left (\frac {x}{2}\right )\right )}\\ \end {align*}
________________________________________________________________________________________
Mathematica [A]
time = 0.48, size = 107, normalized size = 1.00 \begin {gather*} \frac {6 a^2 b \tanh ^{-1}\left (\frac {-b+a \tan \left (\frac {x}{2}\right )}{\sqrt {a^2+b^2}}\right )}{\left (a^2+b^2\right )^{5/2}}+\frac {3 a \left (a^2-b^2\right )+a \left (a^2+b^2\right ) \cos (2 x)-b \left (a^2+b^2\right ) \sin (2 x)}{2 \left (a^2+b^2\right )^2 (a \cos (x)+b \sin (x))} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
________________________________________________________________________________________
Maple [A]
time = 0.24, size = 140, normalized size = 1.31
method | result | size |
default | \(-\frac {4 \left (a b \tan \left (\frac {x}{2}\right )-\frac {a^{2}}{2}+\frac {b^{2}}{2}\right )}{\left (a^{4}+2 a^{2} b^{2}+b^{4}\right ) \left (1+\tan ^{2}\left (\frac {x}{2}\right )\right )}+\frac {4 a^{2} \left (\frac {-\frac {b \tan \left (\frac {x}{2}\right )}{2}-\frac {a}{2}}{a \left (\tan ^{2}\left (\frac {x}{2}\right )\right )-2 b \tan \left (\frac {x}{2}\right )-a}+\frac {3 b \arctanh \left (\frac {2 a \tan \left (\frac {x}{2}\right )-2 b}{2 \sqrt {a^{2}+b^{2}}}\right )}{2 \sqrt {a^{2}+b^{2}}}\right )}{a^{4}+2 a^{2} b^{2}+b^{4}}\) | \(140\) |
risch | \(\frac {{\mathrm e}^{i x}}{-4 i a b +2 a^{2}-2 b^{2}}+\frac {{\mathrm e}^{-i x}}{4 i a b +2 a^{2}-2 b^{2}}+\frac {2 a^{3} {\mathrm e}^{i x}}{\left (-i b \,{\mathrm e}^{2 i x}+a \,{\mathrm e}^{2 i x}+i b +a \right ) \left (i b +a \right )^{2} \left (-i b +a \right )^{2}}-\frac {3 i b \,a^{2} \ln \left ({\mathrm e}^{i x}+\frac {i b +a}{\sqrt {-a^{2}-b^{2}}}\right )}{\sqrt {-a^{2}-b^{2}}\, \left (a^{2}+b^{2}\right )^{2}}+\frac {3 i b \,a^{2} \ln \left ({\mathrm e}^{i x}-\frac {i b +a}{\sqrt {-a^{2}-b^{2}}}\right )}{\sqrt {-a^{2}-b^{2}}\, \left (a^{2}+b^{2}\right )^{2}}\) | \(211\) |
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Maxima [B] Leaf count of result is larger than twice the leaf count of optimal. 253 vs.
\(2 (99) = 198\).
time = 0.50, size = 253, normalized size = 2.36 \begin {gather*} -\frac {3 \, a^{2} b \log \left (\frac {b - \frac {a \sin \left (x\right )}{\cos \left (x\right ) + 1} + \sqrt {a^{2} + b^{2}}}{b - \frac {a \sin \left (x\right )}{\cos \left (x\right ) + 1} - \sqrt {a^{2} + b^{2}}}\right )}{{\left (a^{4} + 2 \, a^{2} b^{2} + b^{4}\right )} \sqrt {a^{2} + b^{2}}} + \frac {2 \, {\left (2 \, a^{3} - a b^{2} - \frac {3 \, a b^{2} \sin \left (x\right )^{2}}{{\left (\cos \left (x\right ) + 1\right )}^{2}} + \frac {3 \, a^{2} b \sin \left (x\right )^{3}}{{\left (\cos \left (x\right ) + 1\right )}^{3}} + \frac {{\left (a^{2} b - 2 \, b^{3}\right )} \sin \left (x\right )}{\cos \left (x\right ) + 1}\right )}}{a^{5} + 2 \, a^{3} b^{2} + a b^{4} + \frac {2 \, {\left (a^{4} b + 2 \, a^{2} b^{3} + b^{5}\right )} \sin \left (x\right )}{\cos \left (x\right ) + 1} + \frac {2 \, {\left (a^{4} b + 2 \, a^{2} b^{3} + b^{5}\right )} \sin \left (x\right )^{3}}{{\left (\cos \left (x\right ) + 1\right )}^{3}} - \frac {{\left (a^{5} + 2 \, a^{3} b^{2} + a b^{4}\right )} \sin \left (x\right )^{4}}{{\left (\cos \left (x\right ) + 1\right )}^{4}}} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Fricas [B] Leaf count of result is larger than twice the leaf count of optimal. 240 vs.
\(2 (99) = 198\).
time = 1.70, size = 240, normalized size = 2.24 \begin {gather*} \frac {2 \, a^{5} - 2 \, a^{3} b^{2} - 4 \, a b^{4} + 2 \, {\left (a^{5} + 2 \, a^{3} b^{2} + a b^{4}\right )} \cos \left (x\right )^{2} - 2 \, {\left (a^{4} b + 2 \, a^{2} b^{3} + b^{5}\right )} \cos \left (x\right ) \sin \left (x\right ) + 3 \, {\left (a^{3} b \cos \left (x\right ) + a^{2} b^{2} \sin \left (x\right )\right )} \sqrt {a^{2} + b^{2}} \log \left (-\frac {2 \, a b \cos \left (x\right ) \sin \left (x\right ) + {\left (a^{2} - b^{2}\right )} \cos \left (x\right )^{2} - 2 \, a^{2} - b^{2} + 2 \, \sqrt {a^{2} + b^{2}} {\left (b \cos \left (x\right ) - a \sin \left (x\right )\right )}}{2 \, a b \cos \left (x\right ) \sin \left (x\right ) + {\left (a^{2} - b^{2}\right )} \cos \left (x\right )^{2} + b^{2}}\right )}{2 \, {\left ({\left (a^{7} + 3 \, a^{5} b^{2} + 3 \, a^{3} b^{4} + a b^{6}\right )} \cos \left (x\right ) + {\left (a^{6} b + 3 \, a^{4} b^{3} + 3 \, a^{2} b^{5} + b^{7}\right )} \sin \left (x\right )\right )}} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Sympy [F(-1)] Timed out
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \text {Timed out} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Giac [A]
time = 0.42, size = 186, normalized size = 1.74 \begin {gather*} -\frac {3 \, a^{2} b \log \left (\frac {{\left | 2 \, a \tan \left (\frac {1}{2} \, x\right ) - 2 \, b - 2 \, \sqrt {a^{2} + b^{2}} \right |}}{{\left | 2 \, a \tan \left (\frac {1}{2} \, x\right ) - 2 \, b + 2 \, \sqrt {a^{2} + b^{2}} \right |}}\right )}{{\left (a^{4} + 2 \, a^{2} b^{2} + b^{4}\right )} \sqrt {a^{2} + b^{2}}} - \frac {2 \, {\left (3 \, a^{2} b \tan \left (\frac {1}{2} \, x\right )^{3} - 3 \, a b^{2} \tan \left (\frac {1}{2} \, x\right )^{2} + a^{2} b \tan \left (\frac {1}{2} \, x\right ) - 2 \, b^{3} \tan \left (\frac {1}{2} \, x\right ) + 2 \, a^{3} - a b^{2}\right )}}{{\left (a \tan \left (\frac {1}{2} \, x\right )^{4} - 2 \, b \tan \left (\frac {1}{2} \, x\right )^{3} - 2 \, b \tan \left (\frac {1}{2} \, x\right ) - a\right )} {\left (a^{4} + 2 \, a^{2} b^{2} + b^{4}\right )}} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Mupad [B]
time = 0.84, size = 224, normalized size = 2.09 \begin {gather*} -\frac {\frac {2\,\left (a\,b^2-2\,a^3\right )}{a^4+2\,a^2\,b^2+b^4}-\frac {2\,\mathrm {tan}\left (\frac {x}{2}\right )\,\left (a^2\,b-2\,b^3\right )}{a^4+2\,a^2\,b^2+b^4}+\frac {6\,a\,b^2\,{\mathrm {tan}\left (\frac {x}{2}\right )}^2}{a^4+2\,a^2\,b^2+b^4}-\frac {6\,a^2\,b\,{\mathrm {tan}\left (\frac {x}{2}\right )}^3}{a^4+2\,a^2\,b^2+b^4}}{-a\,{\mathrm {tan}\left (\frac {x}{2}\right )}^4+2\,b\,{\mathrm {tan}\left (\frac {x}{2}\right )}^3+2\,b\,\mathrm {tan}\left (\frac {x}{2}\right )+a}-\frac {6\,a^2\,b\,\mathrm {atanh}\left (\frac {2\,a^4\,b+2\,b^5+4\,a^2\,b^3-2\,a\,\mathrm {tan}\left (\frac {x}{2}\right )\,\left (a^4+2\,a^2\,b^2+b^4\right )}{2\,{\left (a^2+b^2\right )}^{5/2}}\right )}{{\left (a^2+b^2\right )}^{5/2}} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________